import redis.asyncio as redis

redis_server = None


async def get_tool(key: str) -> str:
    """
    Get the value of a key from Redis.
    """
    if redis_server is None:
        return "Redis server not initialized"

    try:
        client = await redis_server.get_connection()  # type: ignore

        value = await client.get(key)

        if value is not None:
            return f"{value}"
        else:
            return f"key '{key}' notfound"

    except redis.RedisError as e:
        return f"Redis Error: {str(e)}"
    except Exception as e:
        return f"get '{key}' error: {str(e)}"
